import { Injectable } from '@nestjs/common';
import { readJson } from 'fs-extra';
import { join } from 'path';
import { GetJsonParams } from '../interfaces';

@Injectable()
export class AdminService {
  async getJson(params: GetJsonParams): Promise<object> {
    console.log(params);
    const jsonDir = join(
      __dirname,
      '../..',
      params.module,
      params.path,
      `${params.name}.json`,
    );
    console.log(jsonDir);
    return await readJson(jsonDir, { throws: false });
  }
}
